Advanced breakpoints in C#

In the previous chapter, we used to set breakpoints first and it was good. However, there are actually more breakpoints, at least if you are using visual studios unfortunately, it seems Microsoft has disabled these additional debugging features in some of its express versions, but do not worry: they Definitely good, but you can get it without those without access to visual studios, for those who have the most ROCH There are features associated with breakpoint, you can set a breakpoint and right click with the mouse, select the desired function.

Condition

This option allows you to specify a condition that is correct or replaceable, while working with a more useful code to kill a breakpoint, it can actually be useful, where you only want to execute in certain circumstances, for example For you, you may have a loop, there is a tendency of time before reaching the relevant code - in such a situation, you can keep a breakpoint and then a suitable solution. You can configure the location. This is a boring example, which will show you how it works:


static void Main(string[] args)
{
    for(int i = 0; i < 10; i++)
        Console.WriteLine("i is " + i);
}

Set a breakpoint on the line where we output to the console. Run the application now - Each time the loop item breakpoint is triggered. But it may be that whatever we want, maybe we want to do similar hits by defining such a general situation (5th walk):

I == 4

Breakpoints will now be found in slightly, white plus, and when you run the app, it will break when I am equal to variable 4. You can direct the debugger to "stop execution" by using the "has changed" option. The outcome of the above statement has changed, for example, from false to truth

Hit count

With this conversation, you can define an alternate position, the breakpoint of that time has been hit. For example, you can decide that your execution should not be stopped until your breakpoint hits a certain amount. Depending on your needs, and during debug time, there are many options to control this conversation, you can see this dialogue that how many breakpoints have been killed so far.

When the hit ...

By using this conversation, you can define alternative behaviors to hit your breakpoint. This can be useful in many situations, where you do not want to stop execution, but only print a status message or get an active macro. This allows you to define a custom message that will be printed, where you can include all kinds of information about execution. For advanced users, the option of obtaining a specific macro executed when a breakpoint hit is also useful